package com.pos.clothes.service.serviceImpl;

import com.pos.clothes.mapper.DiscountMapper;
import com.pos.clothes.pojo.Discount;
import com.pos.clothes.service.Strategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class declineStrategy implements Strategy {
    @Autowired
    private DiscountMapper mapper;

    @Override
    public float discount(float qian) {

        List<Discount> list = mapper.getBorderDiscount();
        for(int i = list.size()-1;i>=0;i--){
            if(qian>=list.get(i).getBorder()){
                qian = qian - list.get(i).getBorder_rule();
            }
        }
        return qian;
    }
}
